package com.gopay.scheduler.job;

import com.gopay.common.constants.fund.FundFileSourceConstants;
import com.gopay.common.domain.fund.vo.FileBizParam;
import com.gopay.common.util.DateUtils;
import com.gopay.common.util.FastJsonUtil;
import com.gopay.remote.fundcps.service.FileHandlerService;
import com.gopay.scheduler.GopayBaseJob;
import com.gopay.scheduler.service.fund.FundBaseOperateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 基金转国付宝做账02018，备付金加，赎回分红退款账户加
 * @author baiyunpeng
 * @2016年7月14日 下午3:36:05  www.gopay.com.cn Inc.All rights reserved.
 */
public class Fund2GopayTransMoneyJob extends GopayBaseJob {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Resource(name = "fileHandlerService")
    private FileHandlerService fundFileRemoteService;
    @Autowired
    private FundBaseOperateService operateService;

    @Override
    protected void doJobInternal() {
        try {
            String settleDay = DateUtils.format(new Date(), "yyyyMMdd");
            logger.info("【基金转国付宝转账】开始，清算日期：{}",settleDay);

            FileBizParam fileBizParam = new FileBizParam(settleDay, operateService.queryAllFundCorp(), FundFileSourceConstants.CORN);
            fileBizParam.setCheckNotify(true);
            logger.info( "【基金转国付宝转账】传入指令：{}", FastJsonUtil.toJSONString(fileBizParam));
            String res = fundFileRemoteService.fund2GopayTransferMoney(fileBizParam);
            logger.info("【基金转国付宝转账】结束，返回结果：{}",res);
        } catch (Exception e) {
            logger.error("【基金转国付宝转账】异常" , e);
        }
    }
}
